package de.baumann.browser.utils.web3j

import android.os.AsyncTask
import android.widget.TextView
import java.math.BigDecimal

class BalanceTask(var textView: TextView,var d:String = "") : AsyncTask<String, Int, BigDecimal>() {
    override fun doInBackground(vararg p0: String?): BigDecimal {
        val balance = TokenUtil.getBalance(p0[0])
                ?: return BigDecimal(0.0000).setScale(4, BigDecimal.ROUND_DOWN)
        return balance.setScale(4, BigDecimal.ROUND_DOWN)
    }

    override fun onPostExecute(result: BigDecimal?) {
        super.onPostExecute(result)
        textView.text = "${result.toString()} $d"
    }
}